﻿$(function() {
    JSUtility.url = "../../Handler/AjaxHandle.ashx";
    JSUtility.param.ClassName = "OA.Bll.Project.ProjectPaymentPresenter";

    autoResize({ dataGrid: '#Grid', callback: Initlist });
    //alert(IframeHelper.getParentValue('ContractsID'));
    JSUtility.window_edit = $('#Add').window({
        iconCls: 'icon-add',
        zIndex: 1000,
        draggable: true,
        resizable: false,
        shadow: true,
        inline: true,
        modal: true,
        title: '添加项目付款信息',
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: true,
        width: 450,
        closed: true,
        onOpen: function() {
            $('#Add').parent().css("left", "25%");
            $('#Add').parent().next().css("left", "25%");
            $('#Add').parent().next().css("top", "25%");
            $('#Add').parent().css("top", "25%");
        }
    });
    JSUtility.window_edit_form = $("#Add").find("form");
    ComboboxInitial();
    $('#Add').show();
});

function ComboboxInitial() {
    $('#CodeName').combobox({ required: true });
}

function Initlist(size) {

    JSUtility.param.Options["BillId"] = self.parent.billId;
    JSUtility.param.Method = "Search";
    JSUtility.grid = $('#Grid').datagrid({
        tilte: '项目付款信息',
        iconCls: 'icon-save',
        width: size.width,
        height: size.height,
        pageSize: Math.round(size.height / 25),
        pageList: [Math.round(size.height / 25)],
        nowrap: true,
        striped: true,
        url: JSUtility.url,
        queryParams: { "json": $.toJSON(JSUtility.param) },
        sortName: 'Id',
        sortOrder: 'desc',
        idField: 'Id',
        frozenColumns: [[{ title: '编号', field: 'Id', width: 80, sortable: true}]],
        columns: [[
                    { title: '收票编号', field: 'BillId', width: 80 },
                    { title: '付款时间', field: 'PayTime', width: 80 },
                    { title: '付款金额', field: 'PayAmount', width: 100 },
                    { title: '付款单位', field: 'ReceiveCompany', width: 120 }
                  ]],
        pagination: true,
        rownumbers: true,
        singleSelect: true,
        toolbar: [
                    {
                        text: '添加',
                        iconCls: 'icon-add',
                        handler: JSUtility.add
                    }, '-',
                    {
                        text: '修改',
                        iconCls: 'icon-edit',
                        handler: JSUtility.update
                    }, '-',
                    {
                        text: '删除',
                        iconCls: 'icon-remove',
                        handler: JSUtility.del
                    }, '-',
                    {
                        text: '查询',
                        iconCls: 'icon-search',
                        handler: JSUtility.search
                    }
                  ]
    });
}